package com.zhichat.web.controller;

import com.zhichat.entity.SysConfigEntity;
import com.zhichat.service.SysConfigService;
import com.zhichat.web.api.R;
import com.zhichat.web.vo.AppVersionUpdateVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统功能
 *
 * @Author: 团长九哥 https://space.bilibili.com/602197686
 * @CreateDate: 2024/11/18 21:00
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/sys")
public class SysController {

    private final SysConfigService sysConfigService;

    /**
     * 系统配置
     */
    @GetMapping("/config_info")
    public R<SysConfigEntity> getSysConfigInfo() {
        return R.success(sysConfigService.getSysConfigInfo());
    }

    /**
     * APP版本 检测跟新
     */
    @GetMapping("/check_update")
    public R<AppVersionUpdateVO> checkUpdate(String appVersion) {
        return R.success(sysConfigService.checkUpdate(appVersion));
    }

    /**
     * APP版本 下载
     */
    @GetMapping("/download_app")
    public R<String> downloadApp(String appVersion) {
        return R.success(sysConfigService.downloadApp(appVersion));
    }
}
